package com.example.demo.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lee
 * @date 2021年06月14日 15:34
 */
@Configuration
public class EsConfig {
    Logger logger = LoggerFactory.getLogger(EsConfig.class);

    @Bean
    public RestHighLevelClient restHighLevelClient() {
        logger.info("我注册的bean生效了");
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.56.10", 9200,"http")
                )
        );
        return client;
    }
}
